﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masterpage/KhachSan.Master" AutoEventWireup="true" CodeBehind="QL_KhachSan.aspx.cs" Inherits="HotelManagement.ModKhachSan.QL_KhachSan" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Scripts/Jquery/jquery.contextMenu.js" type="text/javascript"></script>
    <link href="../Scripts/Jquery/jquery.contextMenu.css" rel="stylesheet" type="text/css" />        
	<script type="text/javascript">
	<!--
	    $(document).ready(function () {
	        $("#myList UL LI").contextMenu({ menu: 'myMenu' },
                function (action, el, pos) {
                    EventRightClick(action, $(el).text());
                });
	        ClickActiveTab('<%=kindroom %>');
	        ActiveTrangThai('<%=strIDStatusRoom %>')
	    });
	    function ClickActiveTab(id) {
	        $("#container-tabRooms .tabs-nav LI").removeClass('tabs-selected');
	        $("#id" + id.toLowerCase()).addClass('tabs-selected');
	    }
	    function ResetMenuContent() {
	        debugger;
	        $("#myMenu").disableContextMenuItems('#book');
	        $("#myMenu").disableContextMenuItems('#dangky');
	        $("#myMenu").disableContextMenuItems('#chuyenphong');
	        $("#myMenu").disableContextMenuItems('#traphong');
	        $("#myMenu").disableContextMenuItems('#lauchui');
	        $("#myMenu").disableContextMenuItems('#baotri');
	        $("#myMenu").disableContextMenuItems('#Empty');
	    }
	    function SetMenuContent(TinhTrang) {
	        var t = eval(TinhTrang);
	        ResetMenuContent(); // reset menu
	        alert(t);
	        switch (t) {
	            case 0:
	                {
	                    // empty
	                    $("#myMenu").enableContextMenuItems('#book');
	                    $("#myMenu").enableContextMenuItems('#dangky');
	                    $("#myMenu").enableContextMenuItems('#lauchui');
	                    $("#myMenu").enableContextMenuItems('#baotri');
	                }
	            case 1:
	                {
	                    $("#myMenu").enableContextMenuItems('#chuyenphong');
	                    $("#myMenu").enableContextMenuItems('#book');
	                }
	            case 2:
	                {
	                    $("#myMenu").enableContextMenuItems('#book');
	                    $("#myMenu").enableContextMenuItems('#dangky');
	                    $("#myMenu").enableContextMenuItems('#chuyenphong');
	                    $("#myMenu").enableContextMenuItems('#traphong');
	                    $("#myMenu").enableContextMenuItems('#lauchui');
	                }
	            case 3: //clear
	                {
	                    $("#myMenu").enableContextMenuItems('#baotri');
	                    $("#myMenu").enableContextMenuItems('#Empty');
	                }
	            case 4: //addbook
	                {
	                    $("#myMenu").enableContextMenuItems('#book');
	                    $("#myMenu").enableContextMenuItems('#dangky');
	                    $("#myMenu").enableContextMenuItems('#chuyenphong');
	                    $("#myMenu").enableContextMenuItems('#traphong');
	                }
	            case 5:
	                {
	                    $("#myMenu").enableContextMenuItems('#baotri');
	                    $("#myMenu").enableContextMenuItems('#Empty');
	                }

	        }
	    }
    
	    function LoadStatusRoom(NameRoom) {
	        debugger;

	        $.ajax({
	            url: "../Control/AjaxServer/StatusRoom.ashx",
	            data: { 'r': elText },
	            datatype: "text",
	            success: function (result) {
	                if (result != "") {
	                    alert(result);
	                    SetMenuContent(eval(result));
	                }
	            }
	        });
	    }
	    function ActiveTrangThai(id) {
	        $(".bt_trangthai LI a").removeClass('TT_Acrive');
	        if (id != "")
	            $("#" + id).addClass('TT_Acrive');
	    }
	    function GetLinkContextRoom(action, id, tinhtrang, idpdp) {
	        switch (action) {
	            case "book":
	                if (tinhtrang == 0) {
	                    window.open("../ModKhachSan/DatPhongPopUp.aspx", "_self");
	                }
	                else {
	                    alert("Phòng không tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này.");
	                }
	                break;
	            case "lodge":
	                if (tinhtrang == 0 || tinhtrang == 1) {
	                    window.open("../ModKhachSan/DangKyPopUp.aspx?ID=" + idpdp, "_self");
	                }
	                else {
	                    alert("Phòng &#273;ã &#273;&#432;&#7907;c &#273;&#259;ng ký nên không th&#7921;c hi&#7879;n &#273;&#432;&#7907;c ch&#7913;c n&#259;ng này.");
	                }
	                break;
	            case "changeroom":
	                if (tinhtrang == 0) {

	                    alert("Phòng tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này.");
	                }
	                if (tinhtrang == 2) {
	                    window.open("../ModKhachSan/ChuyenPhong.aspx?ID=" + idpdp, "_self");
	                }
	                break;
	            case "checkoutR":
	                if (tinhtrang == 0) {
	                    alert("Phòng tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n &#273;&#432;&#7907;c ch&#7913;c n&#259;ng tr&#7843; phòng.");
	                }
	                if (tinhtrang == 2) {
	                    window.open("../ModKhachSan/TraPhongPopUp.aspx?ID=" + idpdp, "_self");
	                }
	                break;
	            case "minibar":
	                if (tinhtrang == 0) {
	                    alert("Phòng tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này.");
	                }
	                break;
	            case "giatla":
	                if (tinhtrang == 0) {

	                    alert("Phòng tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này.");
	                }
	                break;
	            case "Empty":
	                if (tinhtrang == 1 || tinhtrang == 2 || tinhtrang == 0) {
	                    alert("Phòng tr&#7889;ng nên không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này.");
	                }
	                else {
	                    UpdateStatusRoom(id, 0);
	                }
	                break;
	            case "Dirty":
	                if (tinhtrang == 1) {
	                    alert("Phòng &#273;ang &#273;&#432;&#7907;c &#273;&#7863;t không th&#7875; th&#7921;c hi&#7879;n &#273;&#432;&#7907;c ch&#7913;c n&#259;ng này");
	                } else if (tinhtrang == 2) {
	                    alert("Phòng &#273;ang có ng&#432;&#7901;i &#7903; không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này");
	                } else if (tinhtrang == 3) {
	                    alert("Phòng &#273;ang lau chùi không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này");
	                }
	                else {
	                    UpdateStatusRoom(id, 3);
	                }
	                break;
	            case "Mainte":
	                if (tinhtrang == 1) {
	                    alert("Phòng &#273;ang &#273;&#432;&#7907;c &#273;&#7863;t không th&#7875; th&#7921;c hi&#7879;n &#273;&#432;&#7907;c ch&#7913;c n&#259;ng này");
	                } else if (tinhtrang == 2) {
	                    alert("Phòng &#273;ang có ng&#432;&#7901;i &#7903; không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này");
	                } else if (tinhtrang == 5) {
	                    alert("Phòng &#273;ang lau chùi không th&#7875; th&#7921;c hi&#7879;n ch&#7913;c n&#259;ng này");
	                }
	                else {
	                    UpdateStatusRoom(id, 5);
	                }
	                break;
	        }
	    }
	    //cap nhat trang thai phong
	    function UpdateStatusRoom(id, tinhtrang) {
	        $.ajax({
	            url: "../Control/AjaxServer/updateroom.ashx",
	            data: { 'r': id, 't': tinhtrang },
	            datatype: "text",
	            success: function (result) {
	                if (result == "0") {
	                    location.reload(true);
	                }
	            }
	        });
	    }
	    function EventRightClick(action, elText) {
	        //CheckStatus
	        $.ajax({
	            url: "../Control/AjaxServer/checkstatusroom.ashx",
	            data: { 'r': elText },
	            datatype: "text",
	            success: function (result) {
	                if (result != "") {
	                    var temp = result.split('/');
	                    GetLinkContextRoom(action, temp[0], temp[1], temp[2]);
	                }
	            }
	        });
	    }

   </script> --%>
   <script type="text/javascript">
	    function GetDataRoom(idroom, strroom) {
	        //ResetMenuContent();
	        //LoadStatusRoom(strroom);
	        $("#idnameroom").html(strroom);
	        $.ajax({
	            url: "../Control/AjaxServer/inforoom.ashx",
	            data: { 'r': idroom },
	            datatype: "text",
	            success: function (result) {
	                if (result != "") {
	                    var temp = result.split(';');
	                    if (temp.length > 0) {
	                        $("#<%=ltrHoaDong.ClientID %>").text(temp[0]);
	                        $("#<%=ltrNgayDen.ClientID %>").text(temp[1]);
	                        $("#<%=ltrNgayDi.ClientID %>").text(temp[2]);
	                        $("#<%=ltrKhachHang.ClientID %>").text(temp[3]);
	                        $("#<%=ltrLoaiKhachHang.ClientID %>").text(temp[4]);
	                        $("#<%=ltrMinBar.ClientID %>").text(temp[5]);
	                        $("#<%=ltrGiatLa.ClientID %>").text(temp[6]);
	                        $("#<%=ltrDienThoai.ClientID %>").text(temp[7]);
	                        $("#<%=ltrGiaPhong.ClientID %>").text(temp[8]);
	                    }
	                }
	            }
	        });
	    }     
        </script> 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
     <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" class="right">
	<tr>
		<td align="left" valign="top" >
			<div id="container-tabRooms">                        
				<ul class="tabs-nav">
					<li id="idall"><asp:LinkButton ID="lbtnAllRooms" runat="server" onclick="lbtnAllRooms_Click" ><span>All</span></asp:LinkButton></li>
					<li id="idsingle"><asp:LinkButton ID="lbtnSigleRooms" runat="server" onclick="lbtnSigleRooms_Click" ><span>Single 
                        room</span></asp:LinkButton></li>
					<li id="iddouble"><asp:LinkButton ID="lbtnDoubleRooms" runat="server" onclick="lbtnDoubleRooms_Click" ><span>Double 
                        room</span></asp:LinkButton></li>
					<li id="idluxury"><asp:LinkButton ID="lbtnLuxuryRooms" runat="server" onclick="lbtnLuxuryRooms_Click" ><span>Luxury 
                        room</span></asp:LinkButton></li>
					<li id="idvip"><asp:LinkButton ID="lbtnVipRooms" runat="server" onclick="lbtnVipRooms_Click" ><span>Vip</span></asp:LinkButton></li>							
				</ul>				
				<div class="tabs-container">
				    <div class="conten_right_top_khachsan" id="myList">
			            <ul class="Item_room">
                            <asp:Repeater ID="rptTabRooms" runat="server" 
                                onitemcommand="rptTabRooms_ItemCommand">
                                <ItemTemplate>
                                    <li>
                                        <%--<a href="javascript:GetDataRoom(<%#Eval("IDRoom")%>,<%#Eval("RoomName")%>)" class='<%#Eval("cssCls") %>'  ><%#Eval("RoomName") %></a>--%>
                                    </li>        
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                    </div>				                
				</div>		
			</div>
			<!-- begin context menu -->
			<ul id="myMenu" class="contextMenu">
	            <li class="book"><a href="#book">Đặt phòng</a></li>
	            <li class="dangky"><a href="#lodge">Đăng ký</a></li>
	            <li class="chuyenphong separator"><a href="#changeroom">Chuyển phòng</a></li>
	            <li class="traphong"><a href="#checkoutR">Trả phòng</a></li>    
	            <li class="trong separator"><a href="#Empty">Trống</a></li>	           
	            <li class="lauchui"><a href="#Dirty">Lau chùi</a></li>	           
	            <li class="baotri"><a href="#Mainte">Bảo trì</a></li>	           
            </ul>                
            <!-- end context menu -->
		</td>
	</tr>
	<tr>
		<td height="37" style=" border-left: 1px solid #808080; border-right: 1px solid #808080; background: #e5f0ff url(themes/bg_trangthai.gif) repeat-x top left" valign="middle" >
			<ul class="bt_trangthai">
				<li><span><asp:LinkButton ID="lbtnRefeshRoom" runat="server" CssClass="TT_Refresh" onclick="lbtnRefeshRoom_Click">Refresh</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusAll" runat="server" CssClass="TT_All" onclick="lbtnStatusAll_Click">All</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusEmpty" runat="server" CssClass="TT_Empty" onclick="lbtnStatusEmpty_Click">EMPTY</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusBook" runat="server" CssClass="TT_Book" onclick="lbtnStatusBook_Click">Book</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusLodge" runat="server" CssClass="TT_Lodge" onclick="lbtnStatusLodge_Click">Lodge</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusBookAdd" runat="server" CssClass="TT_AddBook" onclick="lbtnStatusBookAdd_Click">BooK+1</asp:LinkButton></span></li>
				<li><span><asp:LinkButton ID="lbtnStatusDirty" runat="server" CssClass="TT_Dirty" onclick="lbtnStatusDirty_Click">Dirty</asp:LinkButton></span></li>						
				<li><span><asp:LinkButton ID="lbtnStatusMainte" runat="server" CssClass="TT_Mainte" onclick="lbtnStatusMainte_Click">Mainte</asp:LinkButton></span></li>
			</ul>					
			<div class="div_vitri">
			    <asp:Panel ID="pnlFloor" runat="Server" style="float: right; padding-left: 5px;">
		            <asp:DropDownList ID="ddlFloor" runat="server" style="max-width: 70px; height: 20px;" AutoPostBack="true" onselectedindexchanged="ddlFloor_SelectedIndexChanged"></asp:DropDownList>
		        </asp:Panel>
			    <span style="float: right;">
			        <asp:DropDownList ID="ddlBuilding" runat="server" AutoPostBack="true" onselectedindexchanged="ddlBuilding_SelectedIndexChanged" style="max-width: 150px; height: 20px;"></asp:DropDownList>
			    </span>
			</div>
		</td>
	</tr>
	<tr>
		<td style="border-left:1px solid #808080 ; border-right:1px solid #808080 ; border-bottom:1px solid #808080 ;  background-color:#edf5ff; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 12px; " height="100%" valign="top" >
		  <div id="autoDisplayDivBottomKhachSan" class="conten_right_bottom_nhahang_full" >
		      <table cellpadding="0" cellspacing="0" border="0" width="100%"  style="background-color:#edf5ff; font-family: Arial; margin-top: 10px; ">
		        <tr>
		            <td rowspan="3" valign="top" style="width: 90px;" >
		                <div id="idnameroom" style=" border: 1px solid #cccccc; width: 80px; height: 47px; padding-top: 28px; margin: 0px 5px 0px 5px; background-color:#fff; text-align: center; vertical-align: middle; color:#b10554; font-size: 16px;  text-transform: uppercase; font-weight: bold">
		                    Phòng
		                </div>
		            </td>
		            <td>
		                <table cellpadding="0" cellspacing="0" border="0" class="khachsan_id" >
		                     <tr>
		                        <td style="width: 120px; " ><span>Mã hóa &#273;&#417;n:</span></td>
		                        <td style="border-right: 1px solid #cccccc; width: 18%; color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrHoaDong" runat="server"></asp:Label></b></td>
		                        <td style="width: 120px;" ><span>Khách hàng:</span></td>
		                        <td style="border-right: 1px solid #cccccc;width: 18%;color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrKhachHang" runat="server"></asp:Label></b></td>
		                        <td style="width: 120px;" ><span>Lo&#7841;i khách hàng:</span></td>
		                        <td style="width: 18%;color:#b10554; font-weight: bold;" ><b><asp:Label ID="ltrLoaiKhachHang" runat="server"></asp:Label></b></td>
		                    </tr>
		                    <tr>
		                        <td ><span>Giá phòng:</span></td>
		                        <td style="border-right: 1px solid #cccccc;color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrGiaPhong" runat="server"></asp:Label></b></td>
		                        <td ><span>Gi&#7863;t là:</span></td>
		                        <td style="border-right: 1px solid #cccccc;color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrGiatLa" runat="server"></asp:Label></b></td>
		                        <td ><span>Ngày &#272;&#7871;n:</span></td>
		                        <td  style="color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrNgayDen" runat="server"></asp:Label></b></td>
		                    </tr>
		                    <tr>
		                       <td ><span>MiniBar:</span></td>
		                        <td style="border-right: 1px solid #cccccc;color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrMinBar" runat="server"></asp:Label></b></td>
		                        <td ><span>&#272;i&#7879;n tho&#7841;i:</span></td>
		                        <td style="border-right: 1px solid #cccccc;color:#b10554; font-weight: bold;"><b><asp:Label ID="ltrDienThoai" runat="server"></asp:Label></b></td>
		                        <td ><span>Ngày &#273;i:</span></td>
		                        <td style="color:#b10554; font-weight: bold;" ><b><asp:Label ID="ltrNgayDi" runat="server"></asp:Label></b></td>
		                    </tr>
		                </table>
		            </td>
		           </tr>
		                    		        
		      </table>
		  </div>  
		</td>
	</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
